package com.example.poverty.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 定位各种文件或头像地址
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 前端驻村干部头像地址
        registry.addResourceHandler("/img/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                        + "src" + System.getProperty("file.separator")
                        + "main" + System.getProperty("file.separator")
                        + "resources" + System.getProperty("file.separator")
                        + "static" + System.getProperty("file.separator")
                        + "img" + System.getProperty("file.separator")
        );
    }
}
